import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { GridComponent, SupDic } from 'lbf';
import { SFComponent, SFSchema } from '@delon/form';
import { STColumn } from '@delon/abc';
import { Test01Test0105Component } from '../test0105/test0105.component';

@Component({
  selector: 'app-test01-test0104',
  templateUrl: './test0104.component.html',
})
export class Test01Test0104Component implements OnInit {
  params = { sname: 'FR_zbclist', form: {} };

  constructor(private http: _HttpClient, private supdic: SupDic) {}

  @ViewChild('st', { static: false }) st: GridComponent;
  @ViewChild('sf', { static: false }) sf: SFComponent;

  searchSchema: SFSchema = {
    properties: {
      zbzt: {
        type: 'string',
        title: '指标状态',
        enum: this.supdic.getSFDic('zbzt'),
        ui: {
          width: 200,
          widget: 'select',
          allowClear: true,
        },
      },
      zbmc: {
        type: 'string',
        title: '指标名称',
        ui: {
          width: 200,
        },
      },
      zbfl: {
        type: 'string',
        title: '指标分类',
        enum: this.supdic.getSFDic('DAE001'),
        ui: {
          widget: 'select',
          width: 200,
          allowClear: true,
        },
      },
    },
  };

  columns: STColumn[] = [
    { title: '指标编码', index: 'DAA021', statistical: 'count' },
    { title: '指标名称', index: 'DAA022' },
    { title: '指标分类', index: 'ZBFL' },
    { title: '指标数据表', index: 'DAA027' },
    {
      title: '最近更新时间',
      index: 'AAE036',
      type: 'date',
      dateFormat: 'YYYY-MM-DD',
    },
    { title: '数据量', index: 'DAE002' },
    { title: '指标状态', index: 'AAE100', render: 'custom' },
    {
      title: '操作区',
      buttons: [
        {
          text: '查看',
          type: 'modal',
          modal: {
            component: Test01Test0105Component,
          },
          click: (_record, modal, isVisible) => {},
        },
      ],
    },
  ];

  ngOnInit() {}

  query() {
    this.st.reload(this.sf.value);
  }

  export() {}

  changeState() {}
}
